<?php
include 'DBconn.php';
class MarkupHeader
{
    public function addNewMarkup($VObject)
    {
      $cls=array();
      $query="insert into markup_header(markup_code,markup_value,priceA,priceB,priceC,priceD,priceE,priceF,cre_userid,cre_datetime,activestatus) values('$VObject->markup_code','$VObject->markup_value','$VObject->priceA','$VObject->priceB','$VObject->priceC','$VObject->priceD','$VObject->priceE','$VObject->priceF','$VObject->cre_userid','$VObject->cre_datetime',1)";
      $s=mysql_query($query) or die(mysql_error());
      if ($s=1){mysql_query("COMMIT");}
      else{mysql_query("ROLLBACK");}    
      return $this->getAllMarkups();
    }
    public function getAllMarkups()
    {
        $result=mysql_query("select * from markup_header where activestatus=1") or die(mysql_error());
        $res_arr=array();
        while($row=mysql_fetch_object($result))
        {
            $tmp=new VoMarkupHeader();
            $tmp->serialnumber=(int)$row->serialnumber;
            $tmp->markup_code=$row->markup_code;
            $tmp->markup_value=$row->markup_value;
            $tmp->priceA=(double)$row->priceA;
            $tmp->priceB=(double)$row->priceB;
            $tmp->priceC=(double)$row->priceC;
            $tmp->priceD=(double)$row->priceD;
            $tmp->priceE=(double)$row->priceE;
            $tmp->priceF=(double)$row->priceF;
            $tmp->cre_userid=(int)$row->cre_userid;
            $tmp->cre_datetime=$row->cre_datetime;
            $tmp->activestatus=(boolean)$row->activestatus;
            $res_arr[]=$tmp;
        }
         mysql_free_result($result);
    return $res_arr;
    }
    public function editMarkup($VObject)
    {
      $query="update markup_header set markup_code='$VObject->markup_code',markup_value='$$VObject->markup_value',priceA='$VObject->priceA',priceB='$VObject->priceB',priceC='$VObject->priceC',priceD='$VObject->priceD',priceE='$VObject->priceE',priceF='$VObject->priceF',cre_userid='$VObject->cre_userid',cre_datetime='$VObject->cre_datetime' where serialnumber='$VObject->serialnumber'";
      $s=mysql_query($query) or die(mysql_error());
      if ($s=1){mysql_query("COMMIT");}
      else{mysql_query("ROLLBACK");}
      //return $s;
    }
    public function deleteMarkup($serialnumber)
    {
        $s=mysql_query("update markup_header set activestatus=0 where serialnumber='$serialnumber'") or die(mysql_error());
        if ($s=1){mysql_query("COMMIT");}
        else{mysql_query("ROLLBACK");}
        //return $s;
    }
}
//$vo=new VoMarkupHeader();
//$vo->cre_userid=1;
//$vo->serialnumber=10;
//$vo->markup_code="mark1";
//$s=new MarkupHeader;
//echo $s->editMarkup($vo);
class VoMarkupHeader
{
  var $serialnumber;
  var $markup_code;
  var $markup_value;
  var $priceA;
  var $priceB;
  var $priceC;
  var $priceD;
  var $priceE;
  var $priceF;
  var $cre_userid;
  var $cre_datetime;
  var $activestatus;
}
?>